;

function backTop() {
    $(".back-top").click(function () {
        $("html,body").animate({scrollTop:0},"slow");
    });
}
function rightNav() {
    $('.J-trigger').each(function () {
        $(this).mouseover(function () {
            $(this).addClass('z-jdm-tbar-tab-hover');
            if($(this).hasClass('hjd-tbar-tab-qrcode')){
              $(this).find('.toolbar-qrcode').show();
            }
        }).mouseout(function () {
            $(this).removeClass('z-jdm-tbar-tab-hover');
            if($(this).hasClass('hjd-tbar-tab-qrcode')){
                $(this).find('.toolbar-qrcode').hide();
            }
        });
    });

    $('.hjd-toolbar-tabs div[data-type="bar"]').each(function () {
        $(this).on('click',function () {
            var name = $(this).data('name');
            if($(this).hasClass('z-jdm-tbar-tab-selected')){
                $(this).removeClass('z-jdm-tbar-tab-selected');
                $('#hjd-global-toolbar>.hjd-toolbar-wrap').removeClass('z-jdm-toolbar-open');
            }else{
                $('.hjd-toolbar-tabs div[data-type="bar"]').removeClass('z-jdm-tbar-tab-selected');
                $(this).addClass('z-jdm-tbar-tab-selected');
                $('#hjd-global-toolbar>.hjd-toolbar-wrap').addClass('z-jdm-toolbar-open');
                $('#hjd-global-toolbar div.hjd-toolbar-panel[data-name!="'+name+'"]').hide();
                $('#hjd-global-toolbar div.hjd-toolbar-panel[data-name="'+name+'"]').show();
            }
        });
    });
    
    $('#hjd-global-toolbar .J-close').each(function () {
        // $(this).removeClass('z-jdm-tbar-tab-selected');
        $(this).on('click',function () {
            $(this).parents('.hjd-toolbar-wrap').removeClass('z-jdm-toolbar-open');
            var name = $(this).parents('.J-content').data('name');
            $('.hjd-toolbar-tabs div[data-name="'+name+'"]').removeClass('z-jdm-tbar-tab-selected');
        });
    });
    function getCartList() {

    }
}


function startmove(obj,json,fnEnd) {
    clearInterval(obj.timer);
    obj.timer=setInterval(function(){
        var bStop=true;
        for(var attr in json){
            var cur=0;
            if(attr=='opacity'){
                cur=Math.round(parseFloat($(obj).css(attr))*100);
            }else{
                cur=parseInt($(obj).css(attr));
            }

            var speed=(json[attr]-cur)/6;
            speed=speed>0?Math.ceil(speed):Math.floor(speed);
            if(cur!=json[attr])
                bStop=false;
            if(attr=='opacity'){
                obj.style.opacity=(cur+speed)/100;
                obj.style.filter='alpha(opacity:'+(cur+speed)+')';
            }else{
                obj.style[attr]=cur+speed+'px';
            }
        }
        if(bStop){
            clearInterval(obj.timer);
            if(fnEnd)fnEnd();
        }
    },30);
}
function moveTop(obj) {
    var timer = null;
    timer=setInterval(function(){
        var scrollTop=parseInt(document.documentElement.scrollTop||document.body.scrollTop);
        var top=obj.offsetTop-50;
        var speed=0;
        // flag=true;
        if(scrollTop>top){
            speed=-100;
        }else{
            speed=100;
        }
        if(scrollTop<=top+100&&scrollTop>=top-100){
            clearInterval(timer);
            document.documentElement.scrollTop=document.body.scrollTop=top;
        }else{
            document.documentElement.scrollTop=document.body.scrollTop=scrollTop+speed;
        }
    },30);
}


function handleUrl(newData) {
    var url = window.location.href;
    if(!newData || newData == '' || newData == undefined){
        return  url;
    }
    var hostName = url;
    if(url.indexOf("?") >= 1){
        var urlArr = url.split('?')
        hostName = urlArr[0];
        var paramsObj = urlToArr(urlArr[1]);
        if(paramsObj){
            $.extend(paramsObj,newData)
        }
    }else{
        paramsObj = newData;
    }
    return  hostName+"?"+jQuery.param(paramsObj);
}


function urlToArr(uri) {

    uri = decodeURIComponent(uri);
    //拼接数组
    var arrUrl = uri.split('&');
    var urlObj = {};
    var len = arrUrl.length;
    for (var i=0; i<len; i++){
        if(arrUrl[i].indexOf('=')>=1){
            var params = arrUrl[i].split('=');
            if(params[0]!=''&&params[1]!=''){
                urlObj[params[0]] = params[1];
            }
        }
    }

    return $.isEmptyObject(urlObj)?false:urlObj;
}